/**
 * 会员中心 公告
 */

$(document).ready(function(e) {	

	getlist();
	
})
function getlist(currentPage){
	var memberToken = localStorage.getItem('memberToken');
	var requestJson = getSearchParameter(currentPage);
	if(requestJson == false){
		return false;
	}
	$.ajax({
        url: '/euc/_onlineops/getNotice',
        data:requestJson,
        beforeSend: function(request) {
            request.setRequestHeader("token",memberToken );
        },
        dataType: 'JSON',
        async: true,
        contentType:'application/json;charset=utf-8',
        type: 'POST',
        success: function (result, textStatus, response) {
        	//alert(JSON.stringify(result));
        	pageBean = result.data;
        	$("#userTable").empty();	    

        	$.each(result.data.list,function(i,data){
        		html = '<li><a href="javascript:detail('+data.id+');" class="tablelink"><p>'+data.title+'</p><p>'+data.beginTime+'</p></a></li>';
	        	$("#userTable").append(html);
			});
        	$("#totalRow").html(pageBean.totalRow+'&nbsp;');
        	$("#currentPage").html(pageBean.currentPage+'&nbsp;');
        	$("#pageSize").html(pageBean.pageSize+'&nbsp;');        	
        	var pageLength = 15;
        	initailPageNumber(pageBean.totalPage,pageBean.currentPage,pageLength);        	
        	
        },
        error: function () {
        	console.log("error");
        }  
    });
}
function getSearchParameter(currentPage){
	try{

		if(!currentPage) currentPage=1;
		pn = currentPage;
		ps =10;
		requestJson ={"pn":pn,"ps":ps};
		return requestJson;
	}catch(e){
		console.log(e.messge);
	}
	return false;	
}

function detail(id){
	$(".modal-body").load('/euc/_onlineops/notice_detail?notice_id='+id+' #list');
	$('#modalview').modal({
        backdrop: 'static', 
        keyboard: false,
        show: true
    });
	
}